function greeter_1(person:string) { //类型注解
    return "Hello, " + person;
}

let user_1 = "Dongfang";

let user_2 = [0,1,2];


console.log(greeter_1(user_1));
// console.log(greeter(user_2));


// 接口
// 让我们开发这个示例应用。这里我们使用接口来描述一个拥有firstName和lastName字段的对象。
// 在TypeScript里，只在两个类型内部的结构兼容那么这两个类型就是兼容的。
// 这就允许我们在实现接口时候只要保证包含了接口要求的结构就可以，而不必明确地使用 implements语句。
interface Person {
    firstName: string;
    lastName: string;
}

function greeter(person: Person) {
    return "Hello, " + person.firstName + " " + person.lastName;
}

let user = { firstName: "Jane", lastName: "User" };

console.log(greeter(user));


//类
class Student {
    fullName: string;
    constructor(public firstName, public middleInitial, public lastName) {
        this.fullName = firstName + " " + middleInitial + " " + lastName;
    }
}

interface Person {
    firstName: string;
    lastName: string;
}

function greeter2(person : Person) {
    return "Hello, " + person.firstName + " " + person.lastName;
}

let userC = new Student("Jane", "M.", "User");

console.log(greeter2(userC)) ;

// document.body.innerHTML = greeter2(userC)
